// SPDX-License-Identifier: Apache-2.0
import { expect, test } from "bun:test";
import { wavByteArray } from "../src/index.js";

test("mono 48kHz/16 bits", () => {
	expect([
		...wavByteArray(
			{ sampleRate: 48000, channels: 1, length: 7, bits: 16 },
			[-1, -0.5, -0.25, 0, 0.25, 0.5, 1]
		),
	]).toEqual([
		0x52, 0x49, 0x46, 0x46, 0x32, 0x00, 0x00, 0x00, 0x57, 0x41, 0x56, 0x45,
		0x66, 0x6d, 0x74, 0x20, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
		0x80, 0xbb, 0x00, 0x00, 0x00, 0x77, 0x01, 0x00, 0x02, 0x00, 0x10, 0x00,
		0x64, 0x61, 0x74, 0x61, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0xc0,
		0x00, 0xe0, 0x00, 0x00, 0xff, 0x1f, 0xff, 0x3f, 0xff, 0x7f,
	]);
});
